package com.shark.teach;


import lombok.Data;

/**
 * @auther shark
 * @create 2024-07-26 15:33
 */
public class ClassLoaderDemo
{
    public static void main(String[] args)
    {
        Object o = new Object(); //根加载器（BootstrapClassLoader）：由C++实现。
        System.out.println(o.getClass().getClassLoader());

        System.out.println("=======================");
        System.out.println();
        Fish fish = new Fish();

        System.out.println(fish.getClass().getClassLoader());
        System.out.println(fish.getClass().getClassLoader().getParent());
        System.out.println(fish.getClass().getClassLoader().getParent().getParent());

        //双亲委派机制+沙箱安全机制

        //双亲委派机制，自顶向下，逐步求精
        
        String s1 = new String("xy");
        String s2 = new String("xy");

    }
}


@Data
class Fish
{
    //Field
    Integer id;
    String  fishName;

    public Fish() {}

    public int eat()
    {
        return 1;
    }
}